<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
	<base href="<%=basePath%>">
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<!-- basic styles -->
	<link rel="stylesheet" href="assets/css/bootstrap.min.css" />
	<link rel="stylesheet" href="assets/css/bootstrap-responsive.min.css" />
	<link rel="stylesheet" href="assets/css/font-awesome.min.css" />
	<!-- 日期 -->
	<link rel="stylesheet" href="assets/css/bootstrap-datepicker.css" />
	<!-- 下拉框 -->
	<link rel="stylesheet" href="assets/css/chosen.css" />
</head>
<body>
	<form id="addForm" action="channel/channel_save.do" method="post">
		<div class="alert alert-info" style="margin-top:2px;margin-bottom:5px;height:40px;padding-top:10px;padding-bottom:10px;">
			<i class="icon-hand-right"></i>注意：标*的字段为必填项！
		</div>
		<table style="width:100%;border-collapse:separate;border-spacing:5px;">
		<tr>
				<td>名称</td>
				<td><input type="text" name="name"  id="name" maxlength="25"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>频道ID</td>
				<td><input type="text" name="channel_id"  id="channel_id" maxlength="1000"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>推流地址</td>
				<td><input type="text" name="channel_push_url"  id="channel_push_url" maxlength="1000"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>拉流RTP</td>
				<td><input type="text" name="channel_rtp_url"  id="channel_rtp_url" maxlength="1000"   class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>拉流FLV</td>
				<td><input type="text" name="channel_flv_url"  id="channel_flv_url" maxlength="1000"   class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<tr>
				<td>拉流HLS</td>
				<td><input type="text" name="channel_hls_url"  id="channel_hls_url" maxlength="1000"  class="col-xs-10 col-sm-5"/>&nbsp;<span style="color: red">*</span></td>
			</tr>
			<%-- <tr>
				<td>属于供应商</td>
				<td>	
				<select name="agentId" class="chosen-select col-xs-10 col-sm-5" >
						<option value="0" >请选择供应商</option>
						<c:forEach items="${agentList}" var="agent">
							<option value="${agent.id }" >${agent.companyName }</option>
						</c:forEach>
					</select>
				</td>
			</tr> --%>
			<tr>
				<td style="float:center;text-align:center;height:80px;" colspan="2">
					<button type="button" onclick="saveBattery();" class="btn btn-info btn-sm "><i class="icon-edit bigger-120">&nbsp;&nbsp;</i>提交</button>
					<button type="button" onclick="top.Dialog.close();" class="btn btn-info btn-sm "><i class="icon-lightbulb bigger-120">&nbsp;&nbsp;</i>取消</button>
				</td>
			</tr>
		</table>
	</form>
<script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>
	<!-- 引入 -->
	<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
	<!-- 下拉框 -->
	<script type="text/javascript" src="assets/js/chosen.jquery.min.js"></script>
	<!--提示框-->
	<script type="text/javascript" src="assets/js/jquery.tips.js"></script>
	<script type="text/javascript">
	
		$(function() {
			$("table tr").find("td:eq(0)").width(70);
		});
		function saveBattery() {
			if ($("input[name='name']").val() == "") {
				showTips($("input[name='name']"), '请填写名称！');
				return false;
			}
			if ($("input[name='channel_id']").val() == "") {
				showTips($("input[name='channel_id']"), '请填写频道ID！');

				return false;
			}
			if ($("input[name='channel_push_url']").val() == "") {
				showTips($("input[name='channel_push_url']"), '请填写推流地址！');

				return false;
			}
			var channel_push_url = document.getElementById("channel_push_url");
			var reg = /^[^\u4e00-\u9fa5]{0,}$/;
			var result = reg.test(channel_push_url.value);
			if (!result) {
				$("#channel_push_url").tips({
					side : 1,
					msg : '不能输入中文!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			
			if ($("input[name='channel_rtp_url']").val() == "") {
				showTips($("input[name='channel_rtp_url']"), '请填写拉流RTP！');

				return false;
			}
			var channel_rtp_url = document.getElementById("channel_rtp_url");
			var reg = /^[^\u4e00-\u9fa5]{0,}$/;
			var result = reg.test(channel_rtp_url.value);
			if (!result) {
				$("#channel_rtp_url").tips({
					side : 1,
					msg : '不能输入中文!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			if ($("input[name='channel_flv_url']").val() == "") {
				showTips($("input[name='channel_flv_url']"), '请填写拉流FLV！');

				return false;
			}
			var channel_flv_url = document.getElementById("channel_flv_url");
			var reg = /^[^\u4e00-\u9fa5]{0,}$/;
			var result = reg.test(channel_flv_url.value);
			if (!result) {
				$("#channel_flv_url").tips({
					side : 1,
					msg : '不能输入中文!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			
			if ($("input[name='channel_hls_url']").val() == "") {
				showTips($("input[name='channel_hls_url']"), '请填写拉流HLS！');
				return false;
			}
			var channel_hls_url = document.getElementById("channel_hls_url");
			var reg = /^[^\u4e00-\u9fa5]{0,}$/;
			var result = reg.test(channel_hls_url.value);
			if (!result) {
				$("#channel_hls_url").tips({
					side : 1,
					msg : '不能输入中文!',
					bg : '#0099FF',
					time : 3
				});
				return false;
			}
			$("#addForm").submit();
			
		};
		function showTips(obj, tips) {
			obj.tips({
				side : 3,
				msg : tips,
				bg : '#e69138',
				time : 2
			});
		}
	</script>
</body>
</html>